//
//  CreditManager.swift
//  Automobile
//
//  Created by erkebulan elzhan on 7/26/20.
//  Copyright © 2020 erkebulan elzhan. All rights reserved.
//

import Foundation

final class CreditManager {
    static let shared = CreditManager()
    
    /// Процентная ставка
    public func getStavka () -> Double {
        return 8.4
    }
    /// Первый взнос
    public func getFirstInvest (overall: Double) -> Double {
        return overall * 0.1
    }
    /// Платеж в месяц
    public func getMonthCost (srokInYears: Int, overallCost: Double) -> Double {
        let priceTotal: Double = overallCost * (1 + self.getStavka() / 100)
        let allMonthsCost = overallCost -  self.getFirstInvest(overall: overallCost)
        let oneMonthCost = allMonthsCost / Double(((srokInYears * 12) - 1))
        return oneMonthCost
    }
    
}
